﻿//IRecordWrapper.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Plaza.Wrappers
{
	/// <summary>
	/// Предназначен для работы с записями.
	/// </summary>
	interface IRecordWrapper
	{
		/// <summary>
		/// Получение значения поля.
		/// </summary>
		/// <param name="fieldName">Имя поля.</param>
		/// <returns></returns>
		int GetInt(string fieldName);

		/// <summary>
		/// Получение значения поля.
		/// </summary>
		/// <param name="fieldIndex">Индекс поля.</param>
		/// <returns></returns>
		object GetObject(uint fieldIndex);
	}

	class RecordWrapper32 : IRecordWrapper
	{
		private readonly P2ClientGateMTA32.CP2Record _record;

		public RecordWrapper32(P2ClientGateMTA32.CP2Record record)
		{
			_record = record;
		}

		int IRecordWrapper.GetInt(string fieldName)
		{
			return _record.GetValAsLong(fieldName);
		}

		object IRecordWrapper.GetObject(uint fieldIndex)
		{
			return _record.GetValAsVariantByIndex(fieldIndex);
		}
	}

	class RecordWrapper64 : IRecordWrapper
	{
		private readonly P2ClientGateMTA64.CP2Record _record;

		public RecordWrapper64(P2ClientGateMTA64.CP2Record record)
		{
			_record = record;
		}

		int IRecordWrapper.GetInt(string fieldName)
		{
			return _record.GetValAsLong(fieldName);
		}

		object IRecordWrapper.GetObject(uint fieldIndex)
		{
			return _record.GetValAsVariantByIndex(fieldIndex);
		}
	}
}